package com.zsk.shop.controller.app;

/**
 * @author Ys
 * @date 2021年10月26日 14:36
 */

import com.zsk.shop.common.base.BaseResponse;
import com.zsk.shop.model.params.DeliveryAddressParams;
import com.zsk.shop.model.results.DeliveryAddressResult;
import com.zsk.shop.service.DeliveryAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Ys
 * @date 2021年10月26日 10:46
 */
@RestController
@Api(tags = "收货地址")
@RequestMapping("/shop/address")
public class ShopUserAddressController {

    @Resource
    private DeliveryAddressService deliveryAddressService;

    @PostMapping("/getDeliveryAddressList.do")
    @ApiOperation("收货地址列表")
    public BaseResponse<DeliveryAddressResult> getDeliveryAddressList() {
        return deliveryAddressService.getDeliveryAddressList();
    }

    @PostMapping("/saveDeliveryAddress.do")
    @ApiOperation("添加收货地址")
    public BaseResponse saveDeliveryAddress(@RequestBody @Validated DeliveryAddressParams params) {
        return deliveryAddressService.saveOrEditAddress(params);
    }

    @PostMapping("/editDeliveryAddress.do")
    @ApiOperation("编辑收货地址")
    public BaseResponse editDeliveryAddress(@RequestBody @Validated DeliveryAddressParams params) {
        return deliveryAddressService.saveOrEditAddress(params);
    }

    @GetMapping("/deleteDeliveryAddress.do")
    @ApiOperation("删除收货地址")
    public BaseResponse deleteDeliveryAddress(Long id) {
        return deliveryAddressService.deleteDeliveryAddress(id);
    }

}
